/*
 * Copyright (c) 2014 laidian. All Rights Reserved.
 * 
 * @author yaoyuming
 * 
 * @date 2020-05-19 16:04
 */
package com.yao.sys.mapper.sql;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.yao.sys.entity.dto.UserDto;

import cn.hutool.core.util.StrUtil;

/**
 * 用户sql组装
 * 
 * @author yaoyuming
 * @date 2020/05/19 16:04
 */
public class UserWrapper {

    public static Wrapper<UserDto> byName(String userName) {
        return byName(userName, null);
    }

    /**
     * 功能描述 : 按名称查询
     * 
     * @param userName
     * @author yaoyuming
     * @date 2020/4/14
     * @return {@link Wrapper <UserDto>}
     */
    public static Wrapper<UserDto> byName(String userName, Integer id) {
        LambdaQueryWrapper<UserDto> wrapper = Wrappers.lambdaQuery();
        wrapper.eq(StrUtil.isNotEmpty(userName), UserDto::getUserName, userName).ne(null != id, UserDto::getId, id);
        return wrapper;
    }
}